<?php

namespace Trawind\Basics\Commands;

use Illuminate\Console\Command;
use Trawind\Helpers\SystemHelper;
use Trawind\Helpers\WechatHelper;

class SystemMigrateCommand extends Command
{

    /**
     * The console command signature.
     *
     * @var string
     */
    protected $signature = 'system:migrate';


    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'handle system tenants migrate';


    public function handle()
    {
        try {
            $this->call('tenants:migrate');
            SystemHelper::isDevelopEnv() and $this->call('system:field');
        }catch (\Exception $e){
            $this->error($e->getMessage());
            WechatHelper::factory()
                ->migrateExceptionNotice($e->getMessage(),$e->getTraceAsString())
                ->withDeveloper();
        }

        $this->comment('migrate end.');
        return 1;
    }
}